<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$appConfigs.title}</title>

    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
</head> 
<body onpageshow="resetPagination('dg')">
    {datagrid id="dg" datasource="/invest/StrategyInvestMonitorService/findAll.do" view="i_strategy_invest_monitor"}
    {form id="dlg" view="i_strategy_invest_monitor" }
    
    <script>
    field_formatters.status=function (value, row, index){
		if(value == 0)
			return '<font color="red">暂停</font>';
		else if(value == 1)
			return '<font color="green">执行中</font>';
		else if(value == 2)
			return '<font color="red">已结束</font>';
		else if(value == 3)
			return '<font color="green">执行中（仅卖出）</font>';
    }
    field_formatters.invest_status=function (value, row, index){
		if(value == 0)
			return '<font color="yellow">准备中</font>';
		else if(value == 1)
			return '<font color="green">建仓中</font>';
		else if(value == 2)
			return '<font color="green">投资中</font>';
		else if(value == 9)
			return '<font color="red">已结束</font>';
    }
    field_formatters.commission_rate=function (value, row, index){
		if(value)
			return (value * 100)+'%';
    }
    field_formatters.max_profit_rate=function (value, row, index){
		if(value)
			return (value * 100) + '%';
    }
    field_formatters.max_loss_rate=function (value, row, index){
		if(value)
			return (value * 100) + '%';
    }
    field_formatters.investName=function (value, row, index){
		if(value)
			return value;
		else {
			return '<font color="red">所有投资项目</font>';
		}
    }
    field_formatters.check_limit_rate=function (value, row, index){
		if(value == 1)
			return '是';
		else {
			return '否';
		}
    }
    function executeAllStrategies() {
	    postByAjax("/invest/StrategyService/executeAllStrategies.do?type_id=8",null,reload)
    }
    function showInvestSummary() {
	    var row = getDatagrid('dg').datagrid('getSelected');
	    if(row) {
	    	window.parent.openTab(row.name + '的统计','/invest/report/invest_summary.shtml?invest_id='+row.invest_id);
	    } else {
			alert('没有选择投资项目！');
	    }
    }
    </script>
</body>
</html>